package com.ml.loan.sys.controller;


import com.ml.loan.common.annotaion.OperLog;
import com.ml.loan.common.model.JsonResult;
import com.ml.loan.sys.model.SysWebInfo;
import com.ml.loan.sys.service.SysWebInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <p>
 * 网站配置 前端控制器
 * </p>
 *
 * @author mickey
 * @since 2019-12-13
 */
@Controller
@RequestMapping("/syswebinfo")
public class SysWebInfoController {

    @Autowired
    private SysWebInfoService sysWebInfoService;

    @RequestMapping("/viewlist")
    public String viewlist(Model model) {
        model.addAttribute("webInfo", sysWebInfoService.getWebInfo());
        return "system/syswebinfo.html";
    }

    @ResponseBody
    @RequestMapping("/update")
    @OperLog(module = "SYS", desc = "网站配置-更新", result = true)
    public JsonResult update(SysWebInfo webInfo) {
        if (sysWebInfoService.updateById(webInfo)) {
            return JsonResult.ok("修改成功");
        } else {
            return JsonResult.error("修改失败");
        }
    }

}
